#include <bits/stdc++.h>
using namespace std;
int y[5005];
int main(){
    int n, s, a, b, mark = 0;
    cin >> n >> s;
    cin >> a >> b;
    for (int i = 1; i <= n; i++){
        int tx, ty;
        cin >> tx >> ty;
        if (a + b >= tx ){
            mark++;
            y[mark] = ty;
        }
    }
    sort(y + 1, y + mark + 1);
    int ans = 0;
    for (int i = 1; i <= mark; i++){
        if (s >= y[i]){
            ans++;
            s -= y[i];
        }   
        else{
            break;
        }
    }
    cout << ans;
    return 0;
}